//
//  ContentView.swift
//  Movio
//
//  Created by sjl on 2022/8/31.
//

import SwiftUI

final class Person:ObservableObject{
  @Published  var name = 1
    deinit{
        print("销毁")
    }
}

struct ContentView: View {
    @State var count = 0
    var body: some View {
        VStack{
            Text("刷新CounterView计数 :\(count)")
               Button("刷新"){
                   count += 1
            }
           MapView()
        }
    }
}

struct MapView: View {
    @ObservedObject var p = Person()
    var body: some View {
        VStack{
            Text("\(p.name)")
            Button("+1") { //添加一个按钮，指定标题文字为 First button
                p.name += 1
            }
        }
    }
}
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
